<?php
class Testimonial extends CI_Controller{
	private $per_page_index = 1;
	public function __construct(){
		parent::__construct();
		if(!Auth::isLoggedIn() ) redirect("/");
		if($this->session->userdata("type_user") != "superadmin") redirect("/");
		$this->load->model("model_testimonial");
	}
	
	function index($offset=0){
		if($this->input->post("btnChangeStatus") ) {
			$testimonial_id = $this->input->post("testimonial_id");
			$status = $this->input->post("status");
			if($status == 'Y') {
				$status = 'N';
			}else{
				$status = 'Y';
			}
			$this->model_testimonial->changestatus($testimonial_id,$status);
		}
		$data['active_admin_testimonial'] = 'y';
		$data['title'] = TITLE.' - Testimonial';
		
		$count = count($this->model_testimonial->getTestimonial());
		
		$this->load->library('paging');
		$config['base_url']   = base_url().'admin/testimonial/index';
		$config['uri_segment'] = 4;
		$config['total_rows'] = $count;
		$config['per_page']   = $this->per_page_index;
		$data['pagination'] = Paging::setPagination($config);
		
		$params['limit_1'] = $this->per_page_index;
		$params['limit_2'] = $offset;
		$data['testimonial_list'] = $this->model_testimonial->getTestimonial($params);
		
		
		$this->load->view("admin/testimonial",$data);
	}
	
}